<template>
  <view class="container">
    <!-- 服务图片 -->
    <image
      class="service-image"
      :src="serviceDetail.image"
      mode="aspectFill"
    ></image>

    <!-- 服务基本信息 -->
    <view class="service-info">
      <view class="title-price">
        <text class="title">{{ serviceDetail.name }}</text>
        <text class="price">¥{{ serviceDetail.price }}</text>
      </view>
      <view class="tags">
        <text
          class="tag"
          v-for="(tag, index) in serviceDetail.tags"
          :key="index"
          >{{ tag }}</text
        >
      </view>
      <view class="appointment-count">
        <text>已预约{{ serviceDetail.appointmentCount }}次</text>
      </view>
    </view>

    <!-- 服务详情 -->
    <view class="detail-section">
      <view class="section-title">服务介绍</view>
      <view class="section-content">
        <text>{{ serviceDetail.description }}</text>
      </view>
    </view>

    <view class="detail-section">
      <view class="section-title">适用人群</view>
      <view class="section-content">
        <text>{{ serviceDetail.suitableFor }}</text>
      </view>
    </view>

    <view class="detail-section">
      <view class="section-title">注意事项</view>
      <view class="section-content">
        <text>{{ serviceDetail.notice }}</text>
      </view>
    </view>

    <view class="detail-section">
      <view class="section-title">服务流程</view>
      <view class="process-list">
        <view
          class="process-item"
          v-for="(item, index) in serviceDetail.process"
          :key="index"
        >
          <view class="process-step">{{ index + 1 }}</view>
          <text class="process-text">{{ item }}</text>
        </view>
      </view>
    </view>

    <!-- 底部预约栏 -->
    <view class="bottom-bar">
      <view class="price-info">
        <text class="label">总价</text>
        <text class="price">¥{{ serviceDetail.price }}</text>
      </view>
      <button class="appointment-btn" @click="makeAppointment">立即预约</button>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      serviceId: null,
      serviceDetail: {
        id: 1,
        name: "中医内科诊疗",
        price: 200,
        description:
          "通过望闻问切，辨证施治，治疗各种内科疾病。我们的中医师具有丰富的临床经验，能够准确诊断病情，制定个性化的治疗方案。",
        image: "/static/services/service1.jpg",
        tags: ["内科", "诊疗", "中医"],
        appointmentCount: 1234,
        suitableFor:
          "适用于各种内科疾病患者，如感冒、咳嗽、胃痛、失眠等。特别适合长期亚健康状态、慢性病患者及需要调理体质的人群。",
        notice:
          "1. 请提前预约，避免等待时间过长\n2. 就诊时请携带相关检查报告\n3. 治疗期间请遵医嘱，按时服药\n4. 如有不适，请及时复诊",
        process: [
          "预约挂号",
          "医生问诊",
          "中医诊断",
          "制定方案",
          "开具处方",
          "复诊随访",
        ],
      },
    };
  },
  onLoad(options) {
    this.serviceId = options.id;
    // 这里应该根据serviceId获取服务详情
    // this.getServiceDetail();
  },
  methods: {
    makeAppointment() {
      uni.navigateTo({
        url: `/pages/appointment/appointment?serviceId=${this.serviceId}`,
      });
    },
  },
};
</script>

<style lang="scss">
.container {
  min-height: 100vh;
  background-color: #f5f5f5;
  padding-bottom: 120rpx;
}

.service-image {
  width: 100%;
  height: 400rpx;
}

.service-info {
  background-color: #fff;
  padding: 30rpx;

  .title-price {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20rpx;

    .title {
      font-size: 36rpx;
      font-weight: bold;
    }

    .price {
      font-size: 36rpx;
      color: #ff6b6b;
      font-weight: bold;
    }
  }

  .tags {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 20rpx;

    .tag {
      font-size: 24rpx;
      color: #007aff;
      background-color: rgba(0, 122, 255, 0.1);
      padding: 4rpx 12rpx;
      border-radius: 4rpx;
      margin-right: 10rpx;
      margin-bottom: 10rpx;
    }
  }

  .appointment-count {
    font-size: 24rpx;
    color: #999;
  }
}

.detail-section {
  background-color: #fff;
  margin-top: 20rpx;
  padding: 30rpx;

  .section-title {
    font-size: 32rpx;
    font-weight: bold;
    margin-bottom: 20rpx;
    position: relative;
    padding-left: 20rpx;

    &::before {
      content: "";
      position: absolute;
      left: 0;
      top: 50%;
      transform: translateY(-50%);
      width: 6rpx;
      height: 30rpx;
      background-color: #007aff;
      border-radius: 3rpx;
    }
  }

  .section-content {
    font-size: 28rpx;
    color: #666;
    line-height: 1.6;
  }

  .process-list {
    .process-item {
      display: flex;
      align-items: center;
      margin-bottom: 20rpx;

      .process-step {
        width: 40rpx;
        height: 40rpx;
        line-height: 40rpx;
        text-align: center;
        background-color: #007aff;
        color: #fff;
        border-radius: 50%;
        margin-right: 20rpx;
        font-size: 24rpx;
      }

      .process-text {
        font-size: 28rpx;
        color: #666;
      }
    }
  }
}

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100rpx;
  background-color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30rpx;
  box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);

  .price-info {
    .label {
      font-size: 28rpx;
      color: #666;
      margin-right: 10rpx;
    }

    .price {
      font-size: 36rpx;
      color: #ff6b6b;
      font-weight: bold;
    }
  }

  .appointment-btn {
    width: 200rpx;
    height: 70rpx;
    line-height: 70rpx;
    text-align: center;
    background-color: #007aff;
    color: #fff;
    border-radius: 35rpx;
    font-size: 28rpx;
  }
}
</style> 